package accessDBProj;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Map;
import java.util.Vector;

import accessDBProj.AccessDAO;

public class MedicMgLogic {
	private accessDBProj.AccessDAO Dao = new AccessDAO();


	public Vector search(Map map_info) {
		Vector rows=Dao.search(map_info);
		return rows;
	}

	public boolean addRecord(Map row) {
		//性别值转换
		if (Boolean.valueOf(String.valueOf(row.get("jRa_man"))).booleanValue())
			row.put("jRa_man", "1");
		else
			row.put("jRa_man", "0");
		//糖尿历值转换
		if (Boolean.valueOf(String.valueOf(row.get("jCB_DIABE"))).booleanValue())
			row.put("jCB_DIABE", "1");
		else
			row.put("jCB_DIABE", "0");
		return Dao.addRecord (row);
	}

	public void update(Map GUIVal) {
		// TODO 自動生成されたメソッド・スタブ
//		性别值转换
		if (Boolean.valueOf(String.valueOf(GUIVal.get("jRa_man"))).booleanValue())
			GUIVal.put("jRa_man", "1");
		else
			GUIVal.put("jRa_man", "0");
		//糖尿历值转换
		if (Boolean.valueOf(String.valueOf(GUIVal.get("jCB_DIABE"))).booleanValue())
			GUIVal.put("jCB_DIABE", "1");
		else
			GUIVal.put("jCB_DIABE", "0");
		 Dao.update(GUIVal);
	}

	public boolean delete(String mid) {
		return Dao.delete(mid);
	}
//删除多行
	public void delete(int[] rows, Vector table_rows) {
		Vector del_rows=new Vector();
		for (int i=0;i<rows.length;i++){
			del_rows.addElement(table_rows.get(rows[i]));
		}
		Dao.delete(del_rows);
	}

}
